import type { PageParams } from '@/types/common'
import type { Employee } from '@/types/employee'
import type { PutParkSysRoleParams, Role, RoleData, RoleDetail, RoleParams, RoleUserData } from '@/types/system'
import {request} from '@/utils/reuqest'

/**
 * 获取角色列表
 * @returns
 */
export const getRoleListAPI = () => {
  return request<Role[]>('/park/sys/role')
}

/**
 * 获取tree权限列表
 * @returns
 */
export const getTreeListAPI = () => {
  return request<RoleData[]>('/park/sys/permision/all/tree');
}

/**
 * 查询当前角色详情-权限和分配人数
 * @returns
 */
export const getRoleDetailAPI = (roleId: number) => {
  return request<RoleDetail>(`/park/sys/role/${roleId}`)
}

/**
 * 获取角色成员列表
 * @returns
 */
export const getRoleUserAPI = (roleId: number, params?: PageParams) => {
  return request<RoleUserData>(`/park/sys/roleUser/${roleId}`, 'GET', params)
}

/**
 * 角色管理-添加角色
 * @param data 
 * @returns 
 */
export const createRoleUserAPI = (data: RoleParams) => {
  return request('/park/sys/role', 'POST', data)
}

/**
 * 系统管理-角色管理-修改角色
 * @param data 
 * @returns 
 */
export const putParkSysRoleAPI = (data: PutParkSysRoleParams) => {
  return request('/park/sys/role', 'PUT', data)
}
/**
 * 系统管理-角色管理-删除角色
 * @param roleId 
 * @returns 
 */
export const deleteParkSysRoleAPI = (roleId: number) => {
  return request(`/park/sys/role/${roleId}`, 'DELETE')
}

/**
 * 添加员工
 * @returns
 */
export const createEmployeeAPI = (data: Employee) => {
  return request('/park/sys/user', 'POST', data)
}

/**
 * 删除员工
 * @returns
 */
export const delEmployeeAPI = (id: string) => {
  return request(`/park/sys/user/${id}`, 'DELETE')
}

/**
 * 系统管理-用户管理-编辑用户
 * @param data 
 * @returns 
 */
export const putParkSysUserAPI = (data: Employee) => {
  return request('/park/sys/user', 'PUT', data)
}